package mylittleinvestigations;

import mylittleinvestigations.CaseInformation.CaseXmlWriter;
import mylittleinvestigations.CaseInformation.CaseXmlReader;
import java.io.IOException;

public class EvidenceIdPair
{
    public EvidenceIdPair(String evidenceId1, String evidenceId2)
    {
        this.evidenceId1 = evidenceId1;
        this.evidenceId2 = evidenceId2;
    }
    
    private String evidenceId1;
    
    public String getEvidenceId1() { return this.evidenceId1; }
    public void setEvidenceId1(String evidenceId1) { this.evidenceId1 = evidenceId1; }
    
    private String evidenceId2;
    
    public String getEvidenceId2() { return this.evidenceId2; }
    public void setEvidenceId2(String evidenceId2) { this.evidenceId2 = evidenceId2; }

    @Override
    public boolean equals(Object obj)
    {
        if (!(obj instanceof EvidenceIdPair))
        {
            return false;
        }
                
        EvidenceIdPair idPair = (EvidenceIdPair)obj;

        if (idPair == null)
        {
            return false;
        }

        return
            (this.getEvidenceId1().equals(idPair.getEvidenceId1()) && this.getEvidenceId2().equals(idPair.getEvidenceId2())) ||
            (this.getEvidenceId1().equals(idPair.getEvidenceId2()) && this.getEvidenceId2().equals(idPair.getEvidenceId1()));
    }

    @Override
    public int hashCode()
    {
        return this.evidenceId1.hashCode() ^ this.evidenceId2.hashCode();
    }

    public void SaveToXml(CaseXmlWriter writer) throws IOException
    {
        writer.StartElement("EvidenceIdPair");
        writer.WriteTextElement("EvidenceId1", this.evidenceId1);
        writer.WriteTextElement("EvidenceId2", this.evidenceId2);
        writer.EndElement();
    }

    public EvidenceIdPair(CaseXmlReader reader)
    {
        reader.StartElement("EvidenceIdPair");
        this.evidenceId1 = reader.ReadTextElement("EvidenceId1");
        this.evidenceId2 = reader.ReadTextElement("EvidenceId2");
        reader.EndElement();
    }
}